package com.googlecode.mgwt.examples.uibinder.client.activities;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.mgwt.dom.client.event.touch.simple.SimpleTouchEvent;
import com.googlecode.mgwt.ui.client.widget.HeaderButton;

public class ExampleSourceDisplayGwtImpl extends Composite implements ExampleSourceDisplay {

	private static ExampleSourceDisplayGwtImplUiBinder uiBinder = GWT.create(ExampleSourceDisplayGwtImplUiBinder.class);

	interface ExampleSourceDisplayGwtImplUiBinder extends UiBinder<Widget, ExampleSourceDisplayGwtImpl> {
	}

	@UiField
	HeaderButton backButton;

	@UiField
	HTML source;

	private Presenter presenter;

	public ExampleSourceDisplayGwtImpl() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setSource(String html) {
		source.setHTML(html);
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;

	}

	@UiHandler("backButton")
	protected void onBackButtonPressed(SimpleTouchEvent event) {
		if (presenter != null) {
			presenter.onBackButtonPressed();
		}
	}

}
